//
//  ShareNewsPraiseView.m
//  OnionHome
//
//  Created by fengjie on 2019/9/16.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "ShareNewsPraiseView.h"
#import "HomeCommentsController.h"
#import "ForwardingController.h"

@interface ShareNewsPraiseView ()


@end

@implementation ShareNewsPraiseView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}
-(void)createUI{
    [self addSubview:self.shareBtn];
    [self addSubview:self.newsBtn];
    [self addSubview:self.praiseBtn];
//    self.shareBtn.backgroundColor =KRedColor;
    
    [self.shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(44);
        make.top.mas_equalTo(12);
        make.bottom.mas_equalTo(-12);
//        make.width.mas_greaterThanOrEqualTo(60);
    }];
    [self.newsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
    }];
    [self.praiseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-44);
        make.centerY.mas_equalTo(0);
    }];
}
#pragma mark ---k懒加载
-(UIButton*)shareBtn{
    if(!_shareBtn){
        _shareBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_shareBtn setTitle:@"32" forState:UIControlStateNormal];
        [_shareBtn setImage:IMAGE_NAMED(@"ic_repost") forState:UIControlStateNormal];
        [_shareBtn setTitleColor:UIColorFromRGB(0xA6A6AD) forState:UIControlStateNormal];
        _shareBtn.titleLabel.font = SYSTEMFONT(11);
        [_shareBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, -4)];
        _shareBtn.titleLabel.textAlignment =NSTextAlignmentRight;
        
        kWeakSelf(weakSelf);
        [_shareBtn addActionHandler:^{
            [[weakSelf getCurrentViewController] presentViewController:[[BasseNavigationController alloc]initWithRootViewController:[ForwardingController new]] animated:YES completion:nil];
        }];

    }
    return _shareBtn;
}
-(UIButton*)newsBtn{
    if(!_newsBtn){
        _newsBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_newsBtn setTitle:@"22" forState:UIControlStateNormal];
        [_newsBtn setImage:IMAGE_NAMED(@"home_mesae") forState:UIControlStateNormal];
        [_newsBtn setTitleColor:UIColorFromRGB(0xA6A6AD) forState:UIControlStateNormal];
        _newsBtn.titleLabel.font = SYSTEMFONT(11);
        [_newsBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, -4)];

        
        kWeakSelf(weakSelf);
        [_newsBtn addActionHandler:^{
            PresentationObject * objcet = [PresentationObject sharedPresentationObject];
            objcet.subViewFrame = CGRectMake(0, 225, KScreenWidth, KScreenHeight - 225);
            [objcet showPresentingViewController:[weakSelf getCurrentViewController] PresentedViewController:[HomeCommentsController new]];
        }];
    }
    return _newsBtn;
}
-(UIButton*)praiseBtn{
    if(!_praiseBtn){
        _praiseBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_praiseBtn setTitle:@"21" forState:UIControlStateNormal];
        [_praiseBtn setImage:IMAGE_NAMED(@"ic_like_selected") forState:UIControlStateSelected];
        [_praiseBtn setImage:IMAGE_NAMED(@"ic_like_defut") forState:UIControlStateNormal];
        [_praiseBtn setTitleColor:UIColorFromRGB(0xA6A6AD) forState:UIControlStateNormal];
        _praiseBtn.titleLabel.font = SYSTEMFONT(11);
        [_praiseBtn setTitleColor:UIColorFromRGB(0xFF7300) forState:UIControlStateSelected];
        [_praiseBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, -4)];

    }
    return _praiseBtn;
}

@end
